package com.yjjxt

import org.apache.spark.{SparkConf, SparkContext}

object Hello30Accumulator {
  def main(args: Array[String]): Unit = {
    val sparkContext = new SparkContext(new SparkConf().setMaster("local").setAppName("Hello29Broadcast"))
    val lines1 = sparkContext.parallelize(Array("吃1", "喝1", "玩1", "跳1"), 2)
    var count1 = 0;
    lines1.foreach(ele => {
      count1 += 1
    })
    println(count1)

    var accumulator = sparkContext.longAccumulator
    val lines2 = sparkContext.parallelize(Array("吃2", "喝2", "玩2", "跳2"), 2)
    lines2.foreach(ele => {
      accumulator.add(1)
    })
    lines1.count()

    println(accumulator.value)
    sparkContext.stop()
//
//    org.apache.spark.deploy.master.Master
//    org.apache.spark.deploy.worker.Worker


  }
}
